
**TABLE 6 : Heterogeneous Effects by Proxy for Ability**

use "$data\admin_data", clear

**PROB DEFAULT**

*set reps for bootstrap
local r=20000

********
*Initial data steps

*Rename variable because name too long
	rename d_uptake_during_after_LL_new_8 d_f
	
	reg  default_at_maturity female bl_bus_owner d_lleligible age ever_business ///
		HHsize childunder9 land d_bank_deposit COzaat months_CO pos_CO literacy ///
		laxman_bus_knowledge risk_aversion_gen index_optimism_bl fu_dummy* ///
		if (EDT_treat==0 & L_ttreat==0 & d_f ==1 & fu_dummy7==0) , cl(co_code1)
	
	predict za, xb
	
	gen EDT_defa= EDT_treat*za
	gen fem_defa= female*za
	gen EDT_femdefa= EDT_treat*za*female
	gen EDT_feml= EDT_treat*female
	
	gen EDT_elig=(EDT_treat==1 & d_lleligible==1)
	gen EDT_no_elig=(EDT_treat==1 & d_lleligible==0)
	gen nobt_ne=(EDT_treat==0 & d_lleligible==0)
	
	gen EDT_elig_defa=EDT_elig*za
	gen EDT_no_elig_defa=EDT_no_elig*za
	gen nobt_ne_defa=nobt_ne*za
	
	gen EDT_elig_fem=EDT_elig*female
	gen EDT_no_elig_fem=EDT_no_elig*female
	gen nobt_ne_fem=nobt_ne*female
	
	gen EDT_elig_femdefa= EDT_elig*za*female
	gen EDT_no_elig_femdefa= EDT_no_elig*za*female
	gen nobt_ne_femdefa=nobt_ne*za*female

********
*Column (5)
*OLS

*PANEL A ONLY INTERACTION PROB DEFAULT
	local j =1
	foreach vars of varlist loan_uptake_all   {
		set seed 5
		bootstrap, rep(`r'):reg  `vars' EDT_treat EDT_defa za female bl_bus_owner ///
			d_lleligible fu_dummy* if post==0 & fu_dummy7==0, cl(co_code1)
	estimates store `vars'
	sum `vars' if post==0 & fu_dummy7==0 & EDT_treat==0 & L_ttreat==0
	estadd scalar mean_y=r(mean)
	local j = `j'+1
	}
	estout * using "$out/Table6A-Col5.xls", cells("b(star fmt(3))" se(par(`"="("' `")""')))  starlevels(* 0.10 ** 0.05 *** 0.01) ///
		stats(mean_y N r2 , fmt(2 0 2) labels("mean dependent variable" "N.obs" "R-Sq" )) replace
	estimates clear

*PANEL B FEMALE INTERACTION
	local j =1
	foreach vars of varlist loan_uptake_all  {
		set seed 5
		bootstrap, rep(`r'): reg `vars'  EDT_treat EDT_defa EDT_feml fem_defa ///
			EDT_femdefa za female bl_bus_owner d_lleligible fu_dummy* ///
			if post==0 & fu_dummy7==0, cl(co_code1)
		estimates store `vars'
		
		test EDT_treat=EDT_feml
		estadd scalar p_diff1 = r(p)
		test EDT_defa=EDT_femdefa
		estadd scalar p_diff2 = r(p)
		
		sum `vars' if post==0 & fu_dummy7==0 & EDT_treat==0 & L_ttreat==0
		estadd scalar mean_y=r(mean)
		local j = `j'+1
	}
	estout *  using "$out/Table6B-Col5.xls", cells("b(star fmt(3))" ///
		se(par(`"="("' `")""'))) starlevels(* 0.10 ** 0.05 *** 0.01) ///
		stats(mean_y N r2 p_diff1 p_diff2, fmt(2 0 2 2 2) ///
		labels("mean dependent variable" "N.obs" "R-Sq" "p1" "p2")) replace
	estimates clear

********
*Columns (1) and (3)
*Tobit

*PANEL A ONLY INTERACTION PROB DEFAULT
	local j =1
	foreach vars of varlist log_business_worktime_main log_paid_worktime {
		set seed 5
		bootstrap, rep(`r'): tobit  `vars' EDT_treat EDT_defa za female ///
			bl_bus_owner d_lleligible fu_dummy* if post==0 & fu_dummy7==0, ///
			ll ul cl(co_code1)
	estimates store `vars'
	sum `vars' if post==0 & fu_dummy7==0 & EDT_treat==0 & L_ttreat==0
	estadd scalar mean_y=r(mean)
	local j = `j'+1
	}
	estout * using "$out/Table6A-Columns1and3.xls", cells("b(star fmt(3))" ///
		se(par(`"="("' `")""'))) starlevels(* 0.10 ** 0.05 *** 0.01) ///
		stats(mean_y N r2_p , fmt(2 0 2) labels("mean dependent variable" "N.obs" "R-Sq" )) replace
	estimates clear

*PANEL B FEMALE INTERACTION
	local j =1
	foreach vars of varlist log_business_worktime_main log_paid_worktime {
		set seed 5
		bootstrap, rep(`r'): tobit `vars' EDT_treat EDT_defa EDT_feml fem_defa ///
			EDT_femdefa za female bl_bus_owner d_lleligible fu_dummy* ///
			if post==0 & fu_dummy7==0, ll ul cl(co_code1)
		estimates store `vars'
		
		test EDT_treat=EDT_feml
		estadd scalar p_diff1 = r(p)
		test EDT_defa=EDT_femdefa
		estadd scalar p_diff2 = r(p)
		
		sum `vars' if post==0 & fu_dummy7==0 & EDT_treat==0 & L_ttreat==0
		estadd scalar mean_y=r(mean)
		local j = `j'+1
	}
	estout * using "$out/Table6B-Columns1and3.xls", cells("b(star fmt(3))" ///
		se(par(`"="("' `")""'))) starlevels(* 0.10 ** 0.05 *** 0.01) ///
		stats(mean_y N r2_p p_diff1 p_diff2, fmt(2 0 2 2 2) ///
		labels("mean dependent variable" "N.obs" "R-Sq" "p1" "p2")) replace
	estimates clear


**CHANGE IN EXPENDITURE**

********
*Column (6)
*OLS

	use "$data/admin_data.dta", clear
	ren d_uptake_during_after_LL_new_8 d_f

	reg change_log female bl_bus_owner d_lleligible age ever_business HHsize ///
		childunder9 land d_bank_deposit COzaat months_CO pos_CO literacy ///
		laxman_bus_knowledge risk_aversion_gen index_optimism_bl fu_dummy* ///
		if (EDT_treat==0 & L_ttreat==0 & fu_dummy7==0 ) , cl(co_code1)
	
	predict y, xb
	
	egen meany = mean(y)
	egen sdy = sd(y)
	
	gen zy = (y - meany)/sdy
	
	gen EDT_def= EDT_treat*zy
	gen fem_def= female*zy
	gen EDT_fem= EDT_treat*female
	gen EDT_femdef= EDT_treat*zy*female
	
	gen EDT_elig=(EDT_treat==1 & d_lleligible==1)
	gen EDT_no_elig=(EDT_treat==1 & d_lleligible==0)
	gen nobt_ne=(EDT_treat==0 & d_lleligible==0)
	
	gen EDT_elig_def= EDT_elig*zy
	gen EDT_no_elig_def= EDT_no_elig*zy
	gen nobt_ne_def=nobt_ne*zy
	
	gen EDT_elig_fem= EDT_elig*female
	gen EDT_no_elig_fem= EDT_no_elig*female
	gen nobt_ne_fem= nobt_ne*female
	
	gen EDT_elig_femdef= EDT_elig*zy*female
	gen EDT_no_elig_femdef= EDT_no_elig*zy*female
	gen nobt_ne_femdef=nobt_ne*female*zy

*PANEL A ONLY INTERACTION PROB DEFAULT
	local j =1
	foreach vars of varlist loan_uptake_all   {
		set seed 5
		bootstrap, rep(`r'): reg  `vars'  EDT_treat EDT_def zy female bl_bus_owner ///
			d_lleligible fu_dummy* if post==0 & fu_dummy7==0, cl(co_code1)
		estimates store `vars'
		sum `vars' if post==0 & fu_dummy7==0 & EDT_treat==0 & L_ttreat==0
		estadd scalar mean_y=r(mean)
		local j = `j'+1
	}
	estout * using "$out/Table6A-Col6.xls", cells("b(star fmt(3))" se(par(`"="("' `")""'))) ///
		starlevels(* 0.10 ** 0.05 *** 0.01) stats(mean_y N r2 , fmt(2 0 2) ///
		labels("mean dependent variable" "N.obs" "R-Sq" )) replace
	estimates clear

*PANEL B FEMALE INTERACTION
	local j =1
	foreach vars of varlist loan_uptake_all  {
		set seed 5
		bootstrap, rep(`r'): reg `vars'  EDT_treat EDT_def EDT_fem fem_def ///
			EDT_femdef zy female bl_bus_owner d_lleligible fu_dummy* ///
			if post==0 & fu_dummy7==0, cl(co_code1)
		estimates store `vars'
		
		test EDT_treat=EDT_fem
		estadd scalar p_diff1 = r(p)
		test EDT_def=EDT_femdef
		estadd scalar p_diff2 = r(p)
		
		sum `vars' if post==0 & fu_dummy7==0 & EDT_treat==0 & L_ttreat==0
		estadd scalar mean_y=r(mean)
		local j = `j'+1
	}
	estout * using "$out/Table6B-Col6.xls", cells("b(star fmt(3))" ///
		se(par(`"="("' `")""'))) starlevels(* 0.10 ** 0.05 *** 0.01) ///
		stats(mean_y N r2 p_diff1 p_diff2, fmt(2 0 2 2 2) ///
		labels("mean dependent variable" "N.obs" "R-Sq" "p1" "p2")) replace
	estimates clear

********
*Columns (2) and (4)
*Tobit

*PANEL A ONLY INTERACTION PROB DEFAULT
	local j =1
	foreach vars of varlist log_business_worktime_main log_paid_worktime   {
		set seed 5
		bootstrap, rep(`r'): tobit `vars' EDT_treat EDT_def zy female bl_bus_owner ///
			d_lleligible fu_dummy* if post==0 & fu_dummy7==0, ll ul cl(co_code1)
		estimates store `vars'
		sum `vars' if post==0 & fu_dummy7==0 & EDT_treat==0 & L_ttreat==0
		estadd scalar mean_y=r(mean)
		local j = `j'+1
	}
	estout * using "$out/Table6A-Columns2and4.xls", cells("b(star fmt(3))" se(par(`"="("' `")""'))) ///
		starlevels(* 0.10 ** 0.05 *** 0.01) stats(mean_y N r2_p , fmt(2 0 2) ///
		labels("mean dependent variable" "N.obs" "R-Sq" )) replace
	estimates clear

*PANEL B FEMALE INTERACTION
	local j =1
	foreach vars of varlist log_business_worktime_main log_paid_worktime   {
		set seed 5
		bootstrap, rep(`r'): tobit `vars' EDT_treat EDT_def EDT_fem fem_def ///
			EDT_femdef zy female bl_bus_owner d_lleligible fu_dummy* ///
			if post==0 & fu_dummy7==0, ll ul cl(co_code1)
		estimates store `vars'
		
		test EDT_treat=EDT_fem
		estadd scalar p_diff1 = r(p)
		test EDT_def=EDT_femdef
		estadd scalar p_diff2 = r(p)
		
		sum `vars' if post==0 & fu_dummy7==0 & EDT_treat==0 & L_ttreat==0
		estadd scalar mean_y=r(mean)
		local j = `j'+1
	}
	estout * using "$out/Table6B-Columns2and4.xls", cells("b(star fmt(3))" ///
		se(par(`"="("' `")""'))) starlevels(* 0.10 ** 0.05 *** 0.01) ///
		stats(mean_y N r2_p p_diff1 p_diff2, fmt(2 0 2 2 2) ///
		labels("mean dependent variable" "N.obs" "R-Sq" "p1" "p2")) replace
	estimates clear

*Mean of positive among controls 
sum  log_business_worktime_main if post==0 & fu_dummy7==0 & EDT_treat==0 & L_ttreat==0 &  log_business_worktime_main >0 & d_lleligible==1
sum  log_paid_worktime if post==0 & fu_dummy7==0 & EDT_treat==0 & L_ttreat==0 &  log_paid_worktime >0 & d_lleligible==1

*Positive log hours percentages
tab log_business_worktime_main
count if log_business_worktime_main<0
	di 1914/3494
	* = 54.78

tab log_paid_worktime
count if log_paid_worktime<0
	di 2714 /3494
	* = 77.68
